<?php
global $wpsc_query, $wpdb;
get_header();
?>
<section class="content">
    <?php
    $main_category = main_Menu();
    if (is_array($main_category)) {
        foreach ($main_category as $main) {
            ?>
            <div class="list_work list_work2">
                <h2 style="font-weight: bold; margin-bottom: 15px; color: darkorange;"><a href="<?php echo home_url(); ?>?wpsc_product_category=<?php echo $main->slug; ?>"><?php
                    echo $main->name;
                  //  print_r($main);
                    //echo $cate_id;
                    //   $cate_id=  str_replace(' ','',$cate_id);
                    ?></a></h2>
                <ul id="mycarouselnew" class="jcarousel-skin-tango item">
                    <?php
                    wp_reset_query();
                    // $wpsc_query = new wpsc_query(array('category_id' => 5)); category wpsc_product_category
                    $args = array('posts_per_page' => 8,
                        'wpsc_product_category' => $main->slug,
                    );
                    query_posts($args);
                    while (wpsc_have_products()) : wpsc_the_product();
                        ?>
                        <li>
                            <a href="<?php echo esc_url(wpsc_the_product_permalink()); ?>" title="<?php echo wpsc_the_product_title(); ?>">
                                <?php if (wpsc_show_thumbnails()) : ?>
                                    <?php if (wpsc_the_product_thumbnail()) : ?>
                                        <img id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(); ?>">
                                    <?php else: ?>
                                        <img class="no-image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php esc_attr_e('No Image', 'wpsc'); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/noimage.png" width="<?php echo get_option('product_image_width'); ?>" height="<?php echo get_option('product_image_height'); ?>" />
                                    <?php endif; ?>
                                    <?php
                                    if (gold_cart_display_gallery()) :
                                        echo gold_shpcrt_display_gallery(wpsc_the_product_id(), true);
                                    endif;
                                    ?>
                                <?php endif; ?></a>
                            <h3><?php echo get_name(get_the_ID()); ?></h3><br>
                            <span class="price"><small><?php echo substr(wpsc_product_normal_price(), 0, -7); ?>VND&nbsp;</small>giảm còn&nbsp;<h5 class="price_new"><?php echo substr(wpsc_the_product_price(), 0, -7); ?>VND</h5></span>
                            <ul>
                                <li><a href="JavaScript:void(0);" onclick="return click_addtocart(<?php echo wpsc_the_product_id(); ?>);" class="cart tip" title="Mua Hàng">Cart</a></li>
                                <li><a href="<?php echo wpsc_the_product_thumbnail(); ?>" rel="prettyPhoto[gallery2]" class="zoom tip" title="Phóng To">Zoom</a></li>
                            </ul>
                        </li>
                        <form class="product_form"   enctype="multipart/form-data" action="<?php echo get_page_link(31); ?>" 
                              method="post" name="product_<?php echo wpsc_the_product_id(); ?>" 
                              id="product_<?php echo wpsc_the_product_id(); ?>" >
                            <input type="hidden" name="page_id" value="31"/>
                            <input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id"/>
                            <input  type="submit"  value="<?php _e('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button a" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
                        </form>
                        <?php
                    endwhile;
                    // wp_reset_postdata();
                    ?>
                </ul>
            </div><!--end:list_work-->
            <?php //wpsc_print_subcategory("", "");    ?>
        <?php
        }
    }
    ?>
</section>
<?php get_sidebar(); ?>

<?php get_footer(); ?>